﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.UI;

namespace MPBlog.Core
{
    /// <summary>
    /// 所有用户控件的基类，提供访问网站绝对路径的方法
    /// </summary>
    public class UCBase:UserControl
    {
        /// <summary>
        /// 返回当前主题文件夹根目录的绝对路径，以/结尾
        /// </summary>
        public string CurrentThemeAbsoluteRoot(string themeName)
        {
            return Utils.AbsoluteWebRoot + "Admin/Themes/" + themeName + "/";
        }

        /// <summary>
        /// 返回admin文件夹的绝对地址
        /// </summary>
        /// <returns></returns>
        public string AdminAbsoluteRoot()
        {
            return Utils.AbsoluteWebRoot + "Admin/";
        }

        /// <summary>
        /// 返回网站根目录的绝对路径,以/结尾
        /// </summary>
        /// <returns></returns>
        public string AbsoluteRoot()
        {
            return Utils.AbsoluteWebRoot.AbsolutePath;
        }

        /// <summary>
        ///  判断当前是否请求Admin下的页面
        /// </summary>
        protected bool IsAdminRequest
        {
            get
            {
                return Request.Url.AbsolutePath.ToLower().Contains("/admin/");
            }
        }
    }
}
